1 Setup

source("functions.R")
source("functions_sam.R")
library(cytokit)
library(ggedit)
library(kableExtra)
library(monocle)
library(patchwork)
library(readxl)
library(readr)
library(R.utils)
library(Seurat)
library(tidyverse)
library(viridis)
sample <- c("joint_cortex.seurat")
tables_directory <- "tables"
dir.create(tables_directory, showWarnings = FALSE)
monocle_objects_directory <- "monocle_objects"
dir.create(monocle_objects_directory, showWarnings = FALSE)

1.1 Load Seurat objects

input_directory <- "/mnt/KLEINMAN_SCRATCH/projects/sjessa/from_hydra/single_cell/2019-02_revision1/output/atlas-02"
load(file.path(input_directory, "joint_cortex.seurat.Rda"))
seurat <- joint_cortex

1.2 Convert Seurat object to Monocle object.

Interestingly, no oligodendrocyte clusters were found in E12 or E15, so these samples were not included.

selected_clusters <- c(14, 22)
selected_clusters <- paste0("^", selected_clusters, "-")
selected_clusters <- grep(paste(selected_clusters,collapse="|"), levels(seurat@ident), value=TRUE)
# Change cluster name
seurat@meta.data$cluster <- seurat@meta.data$cluster_joint

monocle <- seurat_to_monocle(seurat, selected_clusters)
monocle <- orderCells(monocle, reverse=TRUE)
colours <- monocle@experimentData@other$colours

2 Monocle plots

2.1 Cell trajectories

p <- plot_cell_trajectory(monocle, color_by="cluster", show_branch_points=FALSE) + scale_color_manual(values=colours)
p <- p + theme(legend.title=element_blank())
show(p)

p <- p + facet_wrap(~cluster) + theme(legend.position = "none")
show(p)

plot_cell_trajectory(monocle, color_by="Pseudotime", show_branch_points = TRUE)

plot_cell_trajectory(monocle, color_by="State", show_branch_points=TRUE)

p <- plot_complex_cell_trajectory(monocle, color_by="cluster", show_branch_points=FALSE) + scale_color_manual(values=colours)
p <- p + theme(legend.title=element_blank())
show(p)

2.2 Differentially expressed genes across pseudotime

2.2.1 All genes

diff_test_res_all_genes <- differentialGeneTest(monocle,
      fullModelFormulaStr = "~sm.ns(Pseudotime)", cores=12)
sig_gene_names_all_genes <- row.names(subset(diff_test_res_all_genes, qval < 0.1))
plot_pseudotime_heatmap(monocle[sig_gene_names_all_genes,],
      cores = 12,
      num_clusters=1,
      show_rownames = FALSE)

diff_test_res_all_genes <- diff_test_res_all_genes %>% rownames_to_column("gene")
write.table(diff_test_res_all_genes, file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22_diff_test_res_all_genes.txt"), sep="\t", quote=FALSE, row.names = FALSE)

2.2.2 Transcription factors

input_directory <- "/mnt/KLEINMAN_SCRATCH/projects/blancha/analyses/njabado/single_cell/annotation/animaltfdb3.0"
input_file <- "Mus_musculus_TF.txt"
transcription_factors <- read_tsv(file.path(input_directory, input_file), col_types = cols())

2.2.2.1 Pseudotime heatmaps of significant transcription factors

2.2.2.1.1 q value < 5*10^-5
significant_genes_q_value_5_10_minus_5 <- filter(diff_test_res_all_genes, qval < 5*10^-5) %>% .$gene 
cat("Number of significant genes: ", length(significant_genes_q_value_5_10_minus_5))
## Number of significant genes:  1983
significant_transcription_factors_q_value_5_10_minus_5 <- as.character(significant_genes_q_value_5_10_minus_5[significant_genes_q_value_5_10_minus_5 %in% transcription_factors$Symbol])
cat("Number of significant transcription factors:", length(significant_transcription_factors_q_value_5_10_minus_5))
## Number of significant transcription factors: 100
plot_genes_heatmap_output_q_value_5_10_minus_5 <- plot_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_5_10_minus_5,], cluster_rows=TRUE, num_clusters=3, return_heatmap=TRUE, show_rownames = TRUE)

plot_genes_heatmap_output_q_value_5_10_minus_5 <- plot_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_5_10_minus_5,], cluster_rows=TRUE, num_clusters=1, return_heatmap=TRUE, show_rownames = TRUE)

# The RMarkdown PDF has issues, hence this custom function to save the PDF file.
save_pheatmap_pdf(plot_genes_heatmap_output_q_value_5_10_minus_5[[2]], file.path("figures", "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22", "diff_test_res_plots_transcription_factors_only_q_value_5_10_minus_5_heatmap_custom.pdf"), width=16, height=36)
## pdf 
##   2
heatmap_matrix_q_value_5_10_minus_5 <- plot_genes_heatmap_output_q_value_5_10_minus_5[[1]]
ph_res_q_value_5_10_minus_5 <- plot_genes_heatmap_output_q_value_5_10_minus_5[[2]]
pheatmap_ordering_q_value_5_10_minus_5 <- rownames(heatmap_matrix_q_value_5_10_minus_5[ph_res_q_value_5_10_minus_5$tree_row[["order"]],])

transcription_factors_table_q_value_5_10_minus_5 <- filter(diff_test_res_all_genes, gene %in% significant_transcription_factors_q_value_5_10_minus_5)
# Put genes from the transcription factor table in the same order
transcription_factors_table_q_value_5_10_minus_5 <- transcription_factors_table_q_value_5_10_minus_5 %>% arrange(match(gene, pheatmap_ordering_q_value_5_10_minus_5))

write.table(transcription_factors_table_q_value_5_10_minus_5, file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22-significant_transcription_factors_diff_test_analysis_qval_5_10_minus_5.txt"), sep="\t", quote=FALSE, row.names=FALSE)

heatmap_matrix_q_value_5_10_minus_5 <- plot_genes_heatmap_output_q_value_5_10_minus_5[[1]]
heatmap_matrix_q_value_5_10_minus_5 <- as.data.frame(heatmap_matrix_q_value_5_10_minus_5) %>% rownames_to_column("gene")
heatmap_matrix_q_value_5_10_minus_5 <- heatmap_matrix_q_value_5_10_minus_5 %>% arrange(match(gene, pheatmap_ordering_q_value_5_10_minus_5))
heatmap_matrix_q_value_5_10_minus_5 %>% head(20) %>% kable() %>% kable_styling() %>% scroll_box(height="200px", width="600px")
gene 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
Smarcc1 1.9808307 1.8869484 1.7938039 1.7015379 1.6102875 1.5201861 1.4313635 1.3439458 1.2580556 1.1738123 1.0913316 1.0107264 0.9321062 0.8555779 0.7812455 0.7092104 0.6395719 0.5724270 0.5078707 0.4459967 0.3868969 0.3306623 0.2773830 0.2271487 0.1800486 0.1361722 0.0956094 0.0584508 0.0247883 -0.0052847 -0.0316731 -0.0542793 -0.0730029 -0.0877404 -0.0983847 -0.1048246 -0.1069443 -0.1046231 -0.0977396 -0.0863791 -0.0709098 -0.0517172 -0.0291857 -0.0036999 0.0243545 0.0545896 0.0866143 0.1200337 0.1544486 0.1894550 0.2246437 0.2596007 0.2939066 0.3271373 0.3588640 0.3886541 0.4160712 0.4406768 0.4620304 0.4796913 0.4932192 0.5021763 0.5061283 0.5046465 0.4973095 0.4837051 0.4634327 0.4361055 0.4013530 0.3589047 0.3089514 0.2518468 0.1879541 0.1176447 0.0412961 -0.0407097 -0.1279873 -0.2201496 -0.3168091 -0.4175796 -0.5220771 -0.6299211 -0.7407360 -0.8541523 -0.9698073 -1.0873463 -1.206424 -1.326704 -1.447861 -1.569581 -1.691563 -1.813517 -1.935167 -2.056248 -2.176512 -2.295724 -2.413660 -2.530114 -2.644891 -2.757812
Hmgb3 2.4847649 2.3612506 2.2387326 2.1174024 1.9974462 1.8790451 1.7623746 1.6476046 1.5348988 1.4244149 1.3163042 1.2107117 1.1077761 1.0076296 0.9103980 0.8162010 0.7251522 0.6373594 0.5529251 0.4719463 0.3945154 0.3207206 0.2506463 0.1843737 0.1219813 0.0635460 0.0091434 -0.0411514 -0.0872628 -0.1291139 -0.1666258 -0.1997166 -0.2283003 -0.2522862 -0.2715777 -0.2860713 -0.2956557 -0.3002109 -0.2996120 -0.2939440 -0.2835798 -0.2689060 -0.2503046 -0.2281552 -0.2028372 -0.1747311 -0.1442210 -0.1116951 -0.0775473 -0.0421779 -0.0059941 0.0305894 0.0671503 0.1032591 0.1384791 0.1723667 0.2044727 0.2343427 0.2615183 0.2855386 0.3059414 0.3222647 0.3340489 0.3408387 0.3421850 0.3376477 0.3267982 0.3092223 0.2845236 0.2524084 0.2130510 0.1667939 0.1139934 0.0550179 -0.0097534 -0.0799318 -0.1551210 -0.2349178 -0.3189145 -0.4066995 -0.4978594 -0.5919805 -0.6886505 -0.7874598 -0.8880040 -0.9898850 -1.092713 -1.196109 -1.299705 -1.403148 -1.506099 -1.608237 -1.709258 -1.808881 -1.906841 -2.002899 -2.096836 -2.188458 -2.277591 -2.364086
Ybx1 2.2362754 2.1428771 2.0496497 1.9567171 1.8642029 1.7722303 1.6809226 1.5904026 1.5007928 1.4122155 1.3247930 1.2386470 1.1538992 1.0706709 0.9890833 0.9092575 0.8313140 0.7553736 0.6815566 0.6099832 0.5407735 0.4740475 0.4099249 0.3485256 0.2899692 0.2343753 0.1818634 0.1325532 0.0865642 0.0440160 0.0050284 -0.0302788 -0.0617858 -0.0893724 -0.1129183 -0.1323032 -0.1474061 -0.1581061 -0.1642863 -0.1660197 -0.1636363 -0.1574839 -0.1479101 -0.1352624 -0.1198880 -0.1021344 -0.0823490 -0.0608791 -0.0380725 -0.0142768 0.0101600 0.0348897 0.0595640 0.0838343 0.1073519 0.1297677 0.1507326 0.1698974 0.1869126 0.2014287 0.2130963 0.2215659 0.2264881 0.2275139 0.2242942 0.2164805 0.2037247 0.1856792 0.1619970 0.1323972 0.0969565 0.0558735 0.0093473 -0.0424226 -0.0992364 -0.1608941 -0.2271955 -0.2979401 -0.3729276 -0.4519574 -0.5348290 -0.6213421 -0.7112963 -0.8044913 -0.9007274 -0.9998046 -1.101524 -1.205685 -1.312090 -1.420541 -1.530838 -1.642786 -1.756186 -1.870842 -1.986558 -2.103138 -2.220388 -2.338113 -2.456120 -2.574216
Nr2e1 1.8781158 1.7899168 1.7033417 1.6184981 1.5354848 1.4543924 1.3753031 1.2982918 1.2234262 1.1507672 1.0803696 1.0122825 0.9465500 0.8832112 0.8223012 0.7638516 0.7078905 0.6544438 0.6035351 0.5551864 0.5094188 0.4662529 0.4257092 0.3878087 0.3525736 0.3200277 0.2901968 0.2631096 0.2387979 0.2172976 0.1986487 0.1828967 0.1700925 0.1602936 0.1535648 0.1499786 0.1496163 0.1525691 0.1589338 0.1686224 0.1812888 0.1965715 0.2141081 0.2335330 0.2544747 0.2765539 0.2993818 0.3225591 0.3456752 0.3683083 0.3900256 0.4103843 0.4289329 0.4452134 0.4587638 0.4691213 0.4758262 0.4784258 0.4764798 0.4695650 0.4572814 0.4392584 0.4151611 0.3846964 0.3476205 0.3037447 0.2529421 0.1951534 0.1303920 0.0588267 -0.0188878 -0.1019332 -0.1894895 -0.2807456 -0.3749092 -0.4712148 -0.5689318 -0.6673707 -0.7658882 -0.8638915 -0.9608411 -1.0562527 -1.1496981 -1.2408052 -1.3292566 -1.4147884 -1.497187 -1.576289 -1.651972 -1.724159 -1.792806 -1.857907 -1.919482 -1.977580 -2.032268 -2.083636 -2.131786 -2.176833 -2.218902 -2.258125
Pax6 1.3558933 1.3044440 1.2536696 1.2036512 1.1544660 1.1061876 1.0588856 1.0126262 0.9674723 0.9234836 0.8807168 0.8392258 0.7990622 0.7602751 0.7229115 0.6870168 0.6526346 0.6198074 0.5885764 0.5589822 0.5310649 0.5048643 0.4804203 0.4577730 0.4369636 0.4180338 0.4010269 0.3859878 0.3729633 0.3620027 0.3531580 0.3464842 0.3420399 0.3398879 0.3400950 0.3427334 0.3478804 0.3556193 0.3660359 0.3790354 0.3942734 0.4113854 0.4300027 0.4497502 0.4702453 0.4910965 0.5119028 0.5322539 0.5517303 0.5699039 0.5863397 0.6005972 0.6122329 0.6208035 0.6258683 0.6269941 0.6237587 0.6157562 0.6026018 0.5839372 0.5594367 0.5288129 0.4918226 0.4482728 0.3980265 0.3410080 0.2772082 0.2066883 0.1295841 0.0461821 -0.0427670 -0.1363669 -0.2337320 -0.3339992 -0.4363369 -0.5399539 -0.6441061 -0.7481025 -0.8513095 -0.9531540 -1.0531251 -1.1507751 -1.2457187 -1.3376318 -1.4262491 -1.5113616 -1.592813 -1.670494 -1.744343 -1.814335 -1.880483 -1.942829 -2.001443 -2.056417 -2.107862 -2.155903 -2.200679 -2.242334 -2.281020 -2.316891
Nfia 1.2369566 1.2055009 1.1741786 1.1430303 1.1120963 1.0814162 1.0510293 1.0209742 0.9912893 0.9620122 0.9331802 0.9048301 0.8769983 0.8497208 0.8230330 0.7969700 0.7715665 0.7468569 0.7228752 0.6996551 0.6772301 0.6556332 0.6348976 0.6150558 0.5961407 0.5781846 0.5612201 0.5452795 0.5303955 0.5166005 0.5039271 0.4924083 0.4820771 0.4729669 0.4651114 0.4585447 0.4533014 0.4494166 0.4469235 0.4457509 0.4456862 0.4465074 0.4479925 0.4499198 0.4520674 0.4542132 0.4561348 0.4576098 0.4584154 0.4583291 0.4571286 0.4545920 0.4504984 0.4446282 0.4367634 0.4266883 0.4141900 0.3990592 0.3810907 0.3600843 0.3358459 0.3081878 0.2769307 0.2419039 0.2029470 0.1599112 0.1126607 0.0610739 0.0050453 -0.0554683 -0.1202524 -0.1890022 -0.2614083 -0.3371570 -0.4159322 -0.4974159 -0.5812897 -0.6672361 -0.7549396 -0.8440878 -0.9343730 -1.0254934 -1.1171542 -1.2090690 -1.3009610 -1.3925642 -1.483625 -1.573901 -1.663167 -1.751209 -1.837831 -1.922851 -2.006106 -2.087448 -2.166747 -2.243888 -2.318775 -2.391327 -2.461479 -2.529182
Zfp36l1 1.1006416 1.0749335 1.0493636 1.0239739 0.9988057 0.9738998 0.9492962 0.9250344 0.9011530 0.8776903 0.8546838 0.8321704 0.8101866 0.7887681 0.7679504 0.7477681 0.7282558 0.7094473 0.6913764 0.6740761 0.6575796 0.6419197 0.6271288 0.6132397 0.6002847 0.5882963 0.5773072 0.5673501 0.5584581 0.5506645 0.5440032 0.5385083 0.5342148 0.5311582 0.5293749 0.5289021 0.5297778 0.5320414 0.5357301 0.5407452 0.5468029 0.5536060 0.5608558 0.5682523 0.5754937 0.5822767 0.5882963 0.5932467 0.5968212 0.5987135 0.5986182 0.5962317 0.5912541 0.5833898 0.5723497 0.5578526 0.5396273 0.5174150 0.4909715 0.4600700 0.4245041 0.3840909 0.3386747 0.2881309 0.2323696 0.1713407 0.1050382 0.0335052 -0.0431615 -0.1247494 -0.2106877 -0.3002786 -0.3928125 -0.4875745 -0.5838515 -0.6809394 -0.7781515 -0.8748264 -0.9703362 -1.0640944 -1.1555635 -1.2442609 -1.3297646 -1.4117170 -1.4898275 -1.5638726 -1.633696 -1.699204 -1.760364 -1.817198 -1.869776 -1.918212 -1.962653 -2.003275 -2.040276 -2.073866 -2.104268 -2.131706 -2.156407 -2.178589
Gsx1 0.8215144 0.7712369 0.7218386 0.6734419 0.6261614 0.5801040 0.5353696 0.4920512 0.4502360 0.4100051 0.3714348 0.3345967 0.2995583 0.2663841 0.2351356 0.2058726 0.1786533 0.1535356 0.1305772 0.1098370 0.0913754 0.0752553 0.0615430 0.0503091 0.0416293 0.0355853 0.0322661 0.0317693 0.0342014 0.0396802 0.0483352 0.0603100 0.0757630 0.0948699 0.1178253 0.1448448 0.1761674 0.2120583 0.2528040 0.2984172 0.3485020 0.4026098 0.4602590 0.5209276 0.5840466 0.6489951 0.7150959 0.7816133 0.8477522 0.9126587 0.9754237 1.0350869 1.0906448 1.1410599 1.1852721 1.2222131 1.2508223 1.2700655 1.2789550 1.2765716 1.2620879 1.2347931 1.1941172 1.1396565 1.0711971 0.9887374 0.8925075 0.7829849 0.6609053 0.5274109 0.3846293 0.2349841 0.0808469 -0.0755136 -0.2319779 -0.3866141 -0.5377079 -0.6837840 -0.8236184 -0.9562409 -1.0809299 -1.1971996 -1.3047808 -1.4035979 -1.4937422 -1.5754444 -1.649046 -1.714975 -1.773716 -1.825795 -1.871755 -1.912142 -1.947493 -1.978322 -2.005121 -2.028345 -2.048415 -2.065719 -2.080605 -2.093385
Etv1 0.9260086 0.8835890 0.8416401 0.8002606 0.7595456 0.7195867 0.6804722 0.6422871 0.6051133 0.5690299 0.5341132 0.5004371 0.4680730 0.4370904 0.4075571 0.3795394 0.3531023 0.3283101 0.3052263 0.2839144 0.2644380 0.2468613 0.2312493 0.2176684 0.2061868 0.1968749 0.1898057 0.1850556 0.1827045 0.1828366 0.1855408 0.1909115 0.1990492 0.2100609 0.2240610 0.2411722 0.2615257 0.2852627 0.3125296 0.3432556 0.3770633 0.4135452 0.4522817 0.4928392 0.5347675 0.5775981 0.6208438 0.6639974 0.7065323 0.7479030 0.7875467 0.8248846 0.8593250 0.8902662 0.9171003 0.9392180 0.9560130 0.9668884 0.9712624 0.9685756 0.9582982 0.9399377 0.9130479 0.8772369 0.8321769 0.7776130 0.7133732 0.6393768 0.5556445 0.4624081 0.3605498 0.2511832 0.1354407 0.0144603 -0.1106290 -0.2387202 -0.3687412 -0.4996663 -0.6305273 -0.7604230 -0.8885268 -1.0140931 -1.1364623 -1.2550630 -1.3694134 -1.4791204 -1.583877 -1.683458 -1.777718 -1.866579 -1.950031 -2.028119 -2.100938 -2.168626 -2.231354 -2.289322 -2.342750 -2.391872 -2.436934 -2.478184
Sox9 0.6459327 0.6194119 0.5930953 0.5670639 0.5413977 0.5161748 0.4914719 0.4673646 0.4439265 0.4212305 0.3993479 0.3783490 0.3583030 0.3392784 0.3213427 0.3045630 0.2890059 0.2747378 0.2618250 0.2503341 0.2403319 0.2318861 0.2250649 0.2199381 0.2165765 0.2150529 0.2154420 0.2178208 0.2222690 0.2288691 0.2377071 0.2488726 0.2624591 0.2785645 0.2972915 0.3187476 0.3430461 0.3703059 0.4006468 0.4339781 0.4699143 0.5080399 0.5479286 0.5891417 0.6312268 0.6737182 0.7161360 0.7579869 0.7987649 0.8379520 0.8750203 0.9094329 0.9406468 0.9681147 0.9912879 1.0096193 1.0225666 1.0295959 1.0301854 1.0238306 1.0100480 0.9883813 0.9584069 0.9197404 0.8720443 0.8150357 0.7484955 0.6722785 0.5863243 0.4907677 0.3863716 0.2741395 0.1551205 0.0304019 -0.0988997 -0.2316489 -0.3667031 -0.5029268 -0.6392058 -0.7744635 -0.9076777 -1.0378964 -1.1642534 -1.2859820 -1.4024264 -1.5130495 -1.617437 -1.715299 -1.806465 -1.890879 -1.968587 -2.039727 -2.104515 -2.163228 -2.216191 -2.263765 -2.306330 -2.344276 -2.377994 -2.407866
Foxg1 0.5488428 0.5249359 0.5012581 0.4778899 0.4549098 0.4323941 0.4104175 0.3890529 0.3683716 0.3484432 0.3293363 0.3111178 0.2938541 0.2776103 0.2624512 0.2484408 0.2356432 0.2241225 0.2139430 0.2051695 0.1978678 0.1921048 0.1879489 0.1854703 0.1847413 0.1858369 0.1888350 0.1938167 0.2008671 0.2100754 0.2215358 0.2353476 0.2516159 0.2704524 0.2919758 0.3163125 0.3435972 0.3739741 0.4075916 0.4443809 0.4839629 0.5259231 0.5698300 0.6152329 0.6616595 0.7086150 0.7555811 0.8020165 0.8473568 0.8910163 0.9323900 0.9708561 1.0057799 1.0365180 1.0624232 1.0828507 1.0971639 1.1047426 1.1049901 1.0973423 1.0812764 1.0563207 1.0220644 0.9781680 0.9243732 0.8605137 0.7865246 0.7024521 0.6084617 0.5049501 0.3929901 0.2738853 0.1489467 0.0194743 -0.1132604 -0.2480308 -0.3836700 -0.5190840 -0.6532630 -0.7852902 -0.9143489 -1.0397267 -1.1608175 -1.2771212 -1.3882418 -1.4938825 -1.593840 -1.687998 -1.776319 -1.858832 -1.935630 -2.006855 -2.072691 -2.133356 -2.189094 -2.240165 -2.286843 -2.329407 -2.368135 -2.403304
Creb5 0.8664662 0.8370160 0.8078765 0.7791239 0.7508317 0.7230713 0.6959118 0.6694200 0.6436605 0.6186963 0.5945881 0.5713955 0.5491762 0.5279867 0.5078826 0.4889184 0.4711482 0.4546253 0.4394031 0.4255350 0.4130749 0.4020771 0.3925970 0.3846912 0.3784178 0.3738372 0.3710115 0.3700061 0.3708889 0.3737316 0.3786098 0.3856036 0.3947976 0.4062823 0.4201539 0.4365151 0.4554759 0.4771541 0.5016707 0.5289231 0.5584929 0.5899270 0.6227567 0.6564952 0.6906361 0.7246528 0.7579983 0.7901063 0.8203926 0.8482578 0.8730903 0.8942714 0.9111796 0.9231973 0.9297173 0.9301509 0.9239361 0.9105471 0.8895040 0.8603835 0.8228293 0.7765631 0.7213962 0.6572393 0.5841136 0.5021593 0.4116439 0.3129680 0.2066690 0.0935159 -0.0251140 -0.1476723 -0.2726558 -0.3986317 -0.5242608 -0.6483161 -0.7696988 -0.8874497 -1.0007561 -1.1089542 -1.2115285 -1.3081052 -1.3984448 -1.4824301 -1.5600530 -1.6314004 -1.696639 -1.755999 -1.809763 -1.858247 -1.901795 -1.940763 -1.975510 -2.006395 -2.033764 -2.057953 -2.079278 -2.098035 -2.114501 -2.128929
Sox11 0.7697327 0.7554836 0.7412900 0.7271861 0.7132062 0.6993840 0.6857533 0.6723477 0.6592004 0.6463446 0.6338133 0.6216393 0.6098552 0.5984935 0.5875866 0.5771668 0.5672662 0.5579169 0.5491511 0.5410006 0.5334975 0.5266737 0.5205614 0.5151927 0.5105997 0.5068148 0.5038705 0.5017995 0.5006347 0.5004092 0.5011567 0.5029107 0.5057056 0.5095760 0.5145568 0.5206837 0.5279927 0.5365204 0.5463014 0.5572512 0.5691241 0.5816618 0.5946045 0.6076912 0.6206592 0.6332444 0.6451814 0.6562033 0.6660423 0.6744299 0.6810974 0.6857760 0.6881978 0.6880958 0.6852053 0.6792641 0.6700134 0.6571990 0.6405722 0.6198907 0.5949205 0.5654364 0.5312243 0.4920826 0.4478243 0.3982787 0.3432942 0.2827406 0.2165122 0.1445851 0.0672588 -0.0150508 -0.1019157 -0.1928967 -0.2875452 -0.3854045 -0.4860118 -0.5889001 -0.6936002 -0.7996437 -0.9065654 -1.0139062 -1.1212165 -1.2280593 -1.3340133 -1.4386769 -1.541671 -1.642641 -1.741264 -1.837243 -1.930320 -2.020266 -2.106892 -2.190042 -2.269598 -2.345476 -2.417625 -2.486028 -2.550697 -2.611669
Pbx1 0.3947038 0.3965766 0.3984693 0.4004012 0.4023918 0.4044606 0.4066268 0.4089101 0.4113299 0.4139058 0.4166573 0.4196042 0.4227660 0.4261627 0.4298139 0.4337397 0.4379599 0.4424946 0.4473641 0.4525887 0.4581886 0.4641846 0.4705972 0.4774473 0.4847560 0.4925444 0.5008340 0.5096463 0.5190033 0.5289270 0.5394397 0.5505641 0.5623231 0.5747401 0.5878384 0.6016421 0.6161755 0.6314633 0.6475280 0.6642797 0.6814753 0.6988585 0.7161702 0.7331487 0.7495298 0.7650469 0.7794314 0.7924129 0.8037199 0.8130804 0.8202225 0.8248751 0.8267689 0.8256375 0.8212181 0.8132531 0.8014913 0.7856891 0.7656121 0.7410368 0.7117521 0.6775614 0.6382842 0.5937584 0.5438425 0.4884173 0.4273888 0.3606906 0.2882858 0.2102245 0.1268822 0.0387470 -0.0536864 -0.1499198 -0.2494546 -0.3517940 -0.4564464 -0.5629278 -0.6707648 -0.7794969 -0.8886795 -0.9978858 -1.1067095 -1.2147668 -1.3216979 -1.4271687 -1.530873 -1.632530 -1.731892 -1.828736 -1.922870 -2.014132 -2.102386 -2.187523 -2.269462 -2.348147 -2.423544 -2.495640 -2.564445 -2.629983
Pou3f3 0.5897745 0.5819481 0.5741688 0.5664706 0.5588872 0.5514522 0.5441989 0.5371603 0.5303696 0.5238593 0.5176622 0.5118108 0.5063375 0.5012745 0.4966543 0.4925091 0.4888711 0.4857727 0.4832464 0.4813247 0.4800403 0.4794263 0.4795158 0.4803425 0.4819401 0.4843431 0.4875863 0.4917050 0.4967354 0.5027139 0.5096781 0.5176661 0.5267171 0.5368712 0.5481695 0.5606542 0.5743689 0.5893584 0.6056655 0.6231919 0.6416449 0.6607140 0.6800841 0.6994349 0.7184411 0.7367725 0.7540943 0.7700677 0.7843508 0.7965995 0.8064689 0.8136145 0.8176941 0.8183696 0.8153090 0.8081890 0.7966971 0.7805348 0.7594199 0.7330901 0.7013061 0.6638547 0.6205527 0.5712502 0.5158346 0.4542338 0.3864201 0.3124140 0.2322870 0.1462285 0.0548186 -0.0412318 -0.1412103 -0.2444091 -0.3501317 -0.4576984 -0.5664520 -0.6757631 -0.7850345 -0.8937060 -1.0012570 -1.1072104 -1.2111343 -1.3126436 -1.4114010 -1.5071168 -1.599549 -1.688500 -1.773819 -1.855395 -1.933158 -2.007072 -2.077137 -2.143380 -2.205857 -2.264643 -2.319836 -2.371547 -2.419903 -2.465037
Pou3f2 0.4879578 0.4873613 0.4867886 0.4862634 0.4858094 0.4854502 0.4852095 0.4851110 0.4851784 0.4854354 0.4859056 0.4866130 0.4875812 0.4888344 0.4903964 0.4922913 0.4945435 0.4971773 0.5002173 0.5036883 0.5076152 0.5120233 0.5169381 0.5223855 0.5283917 0.5349832 0.5421869 0.5500304 0.5585416 0.5677488 0.5776812 0.5883683 0.5998406 0.6121290 0.6252654 0.6392823 0.6542132 0.6700927 0.6869526 0.7046823 0.7229738 0.7415003 0.7599292 0.7779219 0.7951344 0.8112175 0.8258181 0.8385794 0.8491431 0.8571507 0.8622451 0.8640731 0.8622877 0.8565509 0.8465365 0.8319331 0.8124481 0.7878104 0.7577752 0.7221272 0.6806847 0.6333043 0.5798843 0.5203695 0.4547544 0.3830879 0.3054758 0.2220845 0.1331430 0.0390073 -0.0595776 -0.1617469 -0.2666489 -0.3734544 -0.4813647 -0.5896204 -0.6975075 -0.8043643 -0.9095859 -1.0126283 -1.1130106 -1.2103171 -1.3041968 -1.3943632 -1.4805918 -1.5627176 -1.640631 -1.714275 -1.783637 -1.848749 -1.909677 -1.966519 -2.019400 -2.068465 -2.113875 -2.155806 -2.194438 -2.229960 -2.262561 -2.292428
Meis2 -0.0785949 -0.0623705 -0.0460733 -0.0296910 -0.0132108 0.0033801 0.0200947 0.0369462 0.0539480 0.0711136 0.0884569 0.1059918 0.1237324 0.1416932 0.1598886 0.1783334 0.1970426 0.2160315 0.2353153 0.2549098 0.2748309 0.2950946 0.3157173 0.3367156 0.3581063 0.3799066 0.4021339 0.4248059 0.4479404 0.4715557 0.4956704 0.5203033 0.5454736 0.5712008 0.5975045 0.6244052 0.6519231 0.6800792 0.7088919 0.7382557 0.7678948 0.7975160 0.8268206 0.8555043 0.8832579 0.9097672 0.9347142 0.9577776 0.9786332 0.9969555 1.0124187 1.0246973 1.0334684 1.0384123 1.0392149 1.0355690 1.0271762 1.0137493 0.9950141 0.9707122 0.9406034 0.9044685 0.8621119 0.8133656 0.7580916 0.6961863 0.6275834 0.5522586 0.4702331 0.3816414 0.2870082 0.1869966 0.0822827 -0.0264492 -0.1385119 -0.2532194 -0.3698927 -0.4878648 -0.6064860 -0.7251296 -0.8431964 -0.9601201 -1.0753718 -1.1884640 -1.2989537 -1.4064461 -1.510595 -1.611107 -1.707737 -1.800293 -1.888631 -1.972655 -2.052312 -2.127591 -2.198520 -2.265159 -2.327597 -2.385949 -2.440350 -2.490953
Tshz2 0.0416828 0.0656549 0.0897702 0.1140113 0.1383603 0.1627991 0.1873087 0.2118700 0.2364633 0.2610682 0.2856642 0.3102300 0.3347440 0.3591843 0.3835281 0.4077526 0.4318344 0.4557495 0.4794738 0.5029825 0.5262507 0.5492529 0.5719633 0.5943558 0.6164041 0.6380813 0.6593605 0.6802143 0.7006154 0.7205359 0.7399480 0.7588236 0.7771346 0.7948527 0.8119495 0.8283966 0.8441658 0.8592286 0.8735550 0.8870430 0.8994921 0.9106932 0.9204367 0.9285123 0.9347100 0.9388209 0.9406379 0.9399568 0.9365768 0.9303022 0.9209433 0.9083173 0.8922502 0.8725777 0.8491467 0.8218168 0.7904618 0.7549714 0.7152524 0.6712305 0.6228518 0.5700844 0.5129198 0.4513741 0.3854899 0.3153368 0.2410131 0.1626458 0.0803924 -0.0055191 -0.0946170 -0.1863561 -0.2802013 -0.3756316 -0.4721438 -0.5692553 -0.6665077 -0.7634687 -0.8597349 -0.9549332 -1.0487220 -1.1407925 -1.2308688 -1.3187085 -1.4041017 -1.4868710 -1.566870 -1.643982 -1.718121 -1.789223 -1.857254 -1.922199 -1.984066 -2.042881 -2.098686 -2.151538 -2.201505 -2.248668 -2.293114 -2.334938
Npas3 0.0095120 0.0354918 0.0615956 0.0878013 0.1140868 0.1404291 0.1668049 0.1931903 0.2195612 0.2458927 0.2721596 0.2983363 0.3243967 0.3503141 0.3760616 0.4016118 0.4269369 0.4520087 0.4767987 0.5012780 0.5254174 0.5491873 0.5725578 0.5954989 0.6179801 0.6399710 0.6614406 0.6823581 0.7026922 0.7224117 0.7414852 0.7598815 0.7775688 0.7945159 0.8106913 0.8260635 0.8406013 0.8542736 0.8670480 0.8788378 0.8894825 0.8988155 0.9066702 0.9128805 0.9172803 0.9197049 0.9199911 0.9179777 0.9135060 0.9064205 0.8965698 0.8838066 0.8679893 0.8489820 0.8266559 0.8008896 0.7715706 0.7385957 0.7018721 0.6613187 0.6168666 0.5684607 0.5160603 0.4596406 0.3991932 0.3347281 0.2662738 0.1938788 0.1176129 0.0376031 -0.0458110 -0.1322201 -0.2212162 -0.3123948 -0.4053568 -0.4997112 -0.5950764 -0.6910828 -0.7873743 -0.8836100 -0.9794659 -1.0746363 -1.1688348 -1.2617956 -1.3532742 -1.4430478 -1.530916 -1.616701 -1.700247 -1.781420 -1.860108 -1.936220 -2.009685 -2.080452 -2.148485 -2.213768 -2.276299 -2.336092 -2.393171 -2.447575
Etv5 1.6120800 1.5011475 1.3930841 1.2880615 1.1862298 1.0877179 0.9926351 0.9010723 0.8131036 0.7287873 0.6481681 0.5712780 0.4981385 0.4287618 0.3631524 0.3013089 0.2432253 0.1888929 0.1383014 0.0914407 0.0483024 0.0088809 -0.0268246 -0.0588088 -0.0870592 -0.1115540 -0.1322608 -0.1491348 -0.1621175 -0.1711342 -0.1760926 -0.1768804 -0.1733629 -0.1653805 -0.1527460 -0.1352414 -0.1126140 -0.0845732 -0.0507928 -0.0112129 0.0338239 0.0839368 0.1387241 0.1977534 0.2605520 0.3265983 0.3953148 0.4660621 0.5381341 0.6107559 0.6830822 0.7541987 0.8231260 0.8888248 0.9502049 1.0061357 1.0554601 1.0970104 1.1296276 1.1521815 1.1635947 1.1628677 1.1491052 1.1215447 1.0795847 1.0228133 0.9510363 0.8643027 0.7629278 0.6476713 0.5204068 0.3834024 0.2389509 0.0893186 -0.0633023 -0.2168386 -0.3693745 -0.5191832 -0.6647520 -0.8047982 -0.9382768 -1.0643805 -1.1825316 -1.2923677 -1.3937224 -1.4866018 -1.571159 -1.647669 -1.716500 -1.778091 -1.832929 -1.881528 -1.924415 -1.962111 -1.995126 -2.023945 -2.049027 -2.070798 -2.089649 -2.105938
heatmap_matrix_q_value_5_10_minus_5 <- left_join(select(transcription_factors_table_q_value_5_10_minus_5, gene, pval, qval, num_cells_expressed), heatmap_matrix_q_value_5_10_minus_5)
write.table(heatmap_matrix_q_value_5_10_minus_5, file = file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22-significant_transcription_factors_diff_test_analysis_qval_5_10_minus_5_heatmap_matrix.txt"), sep="\t", quote=FALSE, row.names=FALSE)
2.2.2.1.2 Ordered pseudotime heatmap (Sam’s function)
ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_5_10_minus_5,], show_rownames=FALSE, return_matrix = FALSE)

ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_5_10_minus_5,], show_rownames=FALSE, return_matrix = FALSE)

ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_5_10_minus_5,], show_rownames=TRUE, return_matrix = TRUE)

ordered_matrix <- as.data.frame(ordered_matrix) %>% rownames_to_column("gene")
ordered_matrix <- left_join(select(transcription_factors_table_q_value_5_10_minus_5, gene, pval, qval, num_cells_expressed), ordered_matrix)
write.table(ordered_matrix, file = file.path(tables_directory, "3_forebrain_oligodendrocytes_joint_forebrain_differential_gene_test_analysis_qval_5_10_minus_5_sam_ordered_heatmap_matrix.txt"), sep="\t", quote=FALSE, row.names=FALSE)
2.2.2.1.3 q value < 0.01
significant_genes_q_value_0.01 <- filter(diff_test_res_all_genes, qval < 0.01) %>% .$gene 
cat("Number of significant genes: ", length(significant_genes_q_value_0.01))
## Number of significant genes:  3288
significant_transcription_factors_q_value_0.01 <- as.character(significant_genes_q_value_0.01[significant_genes_q_value_0.01 %in% transcription_factors$Symbol])
cat("Number of significant transcription factors:", length(significant_transcription_factors_q_value_0.01))
## Number of significant transcription factors: 175
plot_genes_heatmap_output_q_value_0.01 <- plot_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_0.01,], cluster_rows=TRUE, num_clusters=1, return_heatmap=TRUE, show_rownames = TRUE)

save_pheatmap_pdf(plot_genes_heatmap_output_q_value_0.01[[2]], file.path("figures", "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22", "diff_test_plots_transcription_factors_only_q_value_0.01_heatmap_custom.pdf"), width=16, height=40)
## pdf 
##   2
heatmap_matrix_q_value_0.01 <- plot_genes_heatmap_output_q_value_0.01[[1]]
ph_res_q_value_0.01 <- plot_genes_heatmap_output_q_value_0.01[[2]]
pheatmap_ordering_q_value_0.01 <- rownames(heatmap_matrix_q_value_0.01[ph_res_q_value_0.01$tree_row[["order"]],])

transcription_factors_table_q_value_0.01 <- filter(diff_test_res_all_genes, gene %in% significant_transcription_factors_q_value_0.01)
# Put genes from the transcription factor table in the same order
transcription_factors_table_q_value_0.01 <- transcription_factors_table_q_value_0.01 %>% arrange(match(gene, pheatmap_ordering_q_value_0.01))

write.table(transcription_factors_table_q_value_0.01, file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22-significant_transcription_factors_diff_test_analysis_qval_0.01.txt"), sep="\t", quote=FALSE, row.names=FALSE)

heatmap_matrix_q_value_0.01 <- plot_genes_heatmap_output_q_value_0.01[[1]]
heatmap_matrix_q_value_0.01 <- as.data.frame(heatmap_matrix_q_value_0.01) %>% rownames_to_column("gene")
heatmap_matrix_q_value_0.01 <- heatmap_matrix_q_value_0.01 %>% arrange(match(gene, pheatmap_ordering_q_value_0.01))
heatmap_matrix_q_value_0.01 %>% head(20) %>% kable() %>% kable_styling() %>% scroll_box(height="200px", width="600px")
gene 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
Gabpb2 3.000000 3.000000 3.000000 2.759125 2.506764 2.266213 2.037274 1.819712 1.613266 1.4176494 1.2325557 1.0576657 0.8926500 0.7371730 0.5908970 0.4534850 0.3246039 0.2039268 0.0911356 -0.0140775 -0.1120078 -0.2029366 -0.2871300 -0.3648378 -0.4362919 -0.5017061 -0.5612743 -0.6151702 -0.6635461 -0.7065322 -0.7442354 -0.7767381 -0.8040973 -0.8263430 -0.8434762 -0.8554677 -0.8622554 -0.8637417 -0.8597954 -0.8504502 -0.8359812 -0.8166543 -0.7927143 -0.7643914 -0.7319077 -0.6954829 -0.6553401 -0.6117111 -0.5648411 -0.5149938 -0.4624555 -0.4075397 -0.3505905 -0.2919863 -0.2321422 -0.1715125 -0.1105923 -0.0499181 0.0099325 0.0683421 0.1246556 0.1781841 0.2282100 0.2739928 0.3147775 0.3498033 0.3783143 0.3995711 0.4128641 0.4176296 0.4139237 0.4020545 0.3823845 0.3553235 0.3213215 0.2808605 0.2344480 0.1826092 0.1258808 0.0648040 -0.0000808 -0.0682403 -0.1391523 -0.2123107 -0.2872290 -0.3634434 -0.4405155 -0.5180345 -0.5956182 -0.6729144 -0.7496012 -0.8253874 -0.9000116 -0.9732425 -1.0448768 -1.1147393 -1.1826805 -1.2485757 -1.3123231 -1.3738422
Ssrp1 2.989236 2.829115 2.670522 2.513668 2.358756 2.205980 2.055528 1.907580 1.762312 1.6198909 1.4804765 1.3442239 1.2112815 1.0817923 0.9558937 0.8337183 0.7153936 0.6010433 0.4907869 0.3847404 0.2830170 0.1857272 0.0929797 0.0048814 -0.0784618 -0.1569443 -0.2304604 -0.2989039 -0.3621670 -0.4201403 -0.4727116 -0.5197656 -0.5611831 -0.5968403 -0.6266079 -0.6503508 -0.6679268 -0.6791862 -0.6839764 -0.6823806 -0.6748031 -0.6616643 -0.6433784 -0.6203558 -0.5930044 -0.5617312 -0.5269435 -0.4890505 -0.4484638 -0.4055989 -0.3608755 -0.3147186 -0.2675585 -0.2198317 -0.1719806 -0.1244542 -0.0777072 -0.0322006 0.0115993 0.0532208 0.0921883 0.1280221 0.1602402 0.1883592 0.2118951 0.2303653 0.2432900 0.2501937 0.2506072 0.2441520 0.2309104 0.2111267 0.1850536 0.1529504 0.1150825 0.0717200 0.0231373 -0.0303883 -0.0885771 -0.1511481 -0.2178195 -0.2883094 -0.3623371 -0.4396230 -0.5198897 -0.6028624 -0.6882696 -0.7758434 -0.8653202 -0.9564409 -1.0489517 -1.1426039 -1.2371545 -1.3323665 -1.4280092 -1.5238581 -1.6196952 -1.7153093 -1.8104958 -1.9050567
Cdc5l 2.831576 2.668810 2.508251 2.350116 2.194609 2.041924 1.892242 1.745735 1.602564 1.4628783 1.3268198 1.1945201 1.0661028 0.9416831 0.8213691 0.7052620 0.5934570 0.4860437 0.3831072 0.2847285 0.1909851 0.1019525 0.0177040 -0.0616879 -0.1361508 -0.2056115 -0.2699955 -0.3292257 -0.3832218 -0.4318991 -0.4751681 -0.5129330 -0.5450907 -0.5715304 -0.5921317 -0.6067641 -0.6152854 -0.6175410 -0.6133681 -0.6028476 -0.5863959 -0.5644445 -0.5374184 -0.5057385 -0.4698248 -0.4300988 -0.3869853 -0.3409146 -0.2923243 -0.2416603 -0.1893786 -0.1359457 -0.0818396 -0.0275503 0.0264205 0.0795590 0.1313401 0.1812277 0.2286761 0.2731311 0.3140316 0.3508112 0.3829011 0.4097319 0.4307365 0.4453537 0.4530309 0.4532282 0.4454219 0.4292052 0.4047185 0.3723002 0.3323054 0.2851032 0.2310747 0.1706102 0.1041076 0.0319698 -0.0453968 -0.1275849 -0.2141875 -0.3047999 -0.3990213 -0.4964565 -0.5967169 -0.6994220 -0.8042007 -0.9106921 -1.0185467 -1.1274270 -1.2370083 -1.3469792 -1.4570422 -1.5669142 -1.6763262 -1.7850241 -1.8927685 -1.9993342 -2.1045111 -2.2081028
E2f1 2.456768 2.306685 2.161761 2.022044 1.887562 1.758316 1.634293 1.515460 1.401769 1.2931630 1.1895702 1.0909123 0.9971034 0.9080525 0.8236646 0.7438424 0.6684878 0.5975028 0.5307908 0.4682580 0.4098137 0.3553723 0.3048531 0.2581821 0.2152923 0.1761248 0.1406294 0.1087656 0.0805036 0.0558250 0.0347238 0.0172074 0.0032979 -0.0069666 -0.0135311 -0.0163216 -0.0152433 -0.0101793 -0.0009929 0.0122450 0.0291662 0.0493861 0.0725193 0.0981726 0.1259389 0.1553930 0.1860866 0.2175456 0.2492679 0.2807217 0.3113461 0.3405525 0.3677269 0.3922348 0.4134268 0.4306464 0.4432390 0.4505626 0.4520004 0.4469736 0.4349564 0.4154906 0.3882007 0.3528087 0.3091483 0.2571766 0.1969846 0.1288045 0.0530131 -0.0297745 -0.1183344 -0.2112710 -0.3072349 -0.4049484 -0.5032264 -0.6009924 -0.6972900 -0.7912888 -0.8822873 -0.9697111 -1.0531087 -1.1321438 -1.2065870 -1.2763049 -1.3412488 -1.4014433 -1.4569749 -1.5079804 -1.5546370 -1.5971519 -1.6357546 -1.6706884 -1.7022040 -1.7305545 -1.7559899 -1.7787543 -1.7990825 -1.8171979 -1.8333114 -1.8476202
Nr2e1 1.878116 1.789917 1.703342 1.618498 1.535485 1.454392 1.375303 1.298292 1.223426 1.1507672 1.0803696 1.0122825 0.9465500 0.8832112 0.8223012 0.7638516 0.7078905 0.6544438 0.6035351 0.5551864 0.5094188 0.4662529 0.4257092 0.3878087 0.3525736 0.3200277 0.2901968 0.2631096 0.2387979 0.2172976 0.1986487 0.1828967 0.1700925 0.1602936 0.1535648 0.1499786 0.1496163 0.1525691 0.1589338 0.1686224 0.1812888 0.1965715 0.2141081 0.2335330 0.2544747 0.2765539 0.2993818 0.3225591 0.3456752 0.3683083 0.3900256 0.4103843 0.4289329 0.4452134 0.4587638 0.4691213 0.4758262 0.4784258 0.4764798 0.4695650 0.4572814 0.4392584 0.4151611 0.3846964 0.3476205 0.3037447 0.2529421 0.1951534 0.1303920 0.0588267 -0.0188878 -0.1019332 -0.1894895 -0.2807456 -0.3749092 -0.4712148 -0.5689318 -0.6673707 -0.7658882 -0.8638915 -0.9608411 -1.0562527 -1.1496981 -1.2408052 -1.3292566 -1.4147884 -1.4971875 -1.5762888 -1.6519722 -1.7241586 -1.7928062 -1.8579070 -1.9194824 -1.9775798 -2.0322683 -2.0836360 -2.1317860 -2.1768333 -2.2189025 -2.2581248
Smarcc1 1.980831 1.886948 1.793804 1.701538 1.610288 1.520186 1.431364 1.343946 1.258056 1.1738123 1.0913316 1.0107264 0.9321062 0.8555779 0.7812455 0.7092104 0.6395719 0.5724270 0.5078707 0.4459967 0.3868969 0.3306623 0.2773830 0.2271487 0.1800486 0.1361722 0.0956094 0.0584508 0.0247883 -0.0052847 -0.0316731 -0.0542793 -0.0730029 -0.0877404 -0.0983847 -0.1048246 -0.1069443 -0.1046231 -0.0977396 -0.0863791 -0.0709098 -0.0517172 -0.0291857 -0.0036999 0.0243545 0.0545896 0.0866143 0.1200337 0.1544486 0.1894550 0.2246437 0.2596007 0.2939066 0.3271373 0.3588640 0.3886541 0.4160712 0.4406768 0.4620304 0.4796913 0.4932192 0.5021763 0.5061283 0.5046465 0.4973095 0.4837051 0.4634327 0.4361055 0.4013530 0.3589047 0.3089514 0.2518468 0.1879541 0.1176447 0.0412961 -0.0407097 -0.1279873 -0.2201496 -0.3168091 -0.4175796 -0.5220771 -0.6299211 -0.7407360 -0.8541523 -0.9698073 -1.0873463 -1.2064237 -1.3267036 -1.4478608 -1.5695814 -1.6915634 -1.8135174 -1.9351667 -2.0562483 -2.1765125 -2.2957237 -2.4136600 -2.5301137 -2.6448910 -2.7578117
Arid4a 1.515844 1.449813 1.384404 1.319722 1.255870 1.192945 1.131043 1.070256 1.010673 0.9523803 0.8954619 0.8399983 0.7860682 0.7337477 0.6831110 0.6342305 0.5871766 0.5420187 0.4988245 0.4576610 0.4185944 0.3816902 0.3470139 0.3146308 0.2846065 0.2570074 0.2319004 0.2093539 0.1894377 0.1722233 0.1577846 0.1461978 0.1375421 0.1319000 0.1293577 0.1300054 0.1339379 0.1412551 0.1520577 0.1662634 0.1835378 0.2035291 0.2258848 0.2502500 0.2762664 0.3035713 0.3317968 0.3605692 0.3895086 0.4182287 0.4463372 0.4734352 0.4991188 0.5229788 0.5446022 0.5635732 0.5794744 0.5918888 0.6004013 0.6046006 0.6040821 0.5984497 0.5873189 0.5703195 0.5470985 0.5173238 0.4806869 0.4369066 0.3857327 0.3270263 0.2611006 0.1884288 0.1094951 0.0247913 -0.0651866 -0.1599414 -0.2589778 -0.3618052 -0.4679401 -0.5769088 -0.6882494 -0.8015139 -0.9162699 -1.0321025 -1.1486150 -1.2654309 -1.3821940 -1.4985698 -1.6142454 -1.7289305 -1.8423569 -1.9542787 -2.0644722 -2.1727353 -2.2788874 -2.3827683 -2.4842376 -2.5831743 -2.6794752 -2.7730544
Pou6f1 2.694772 2.490870 2.294437 2.105546 1.924230 1.750490 1.584292 1.425576 1.274259 1.1302342 0.9933817 0.8635656 0.7406395 0.6244491 0.5148345 0.4116330 0.3146808 0.2238158 0.1388789 0.0597162 -0.0138197 -0.0818677 -0.1445574 -0.2020070 -0.2543225 -0.3015958 -0.3439042 -0.3813084 -0.4138512 -0.4415563 -0.4644262 -0.4824410 -0.4955561 -0.5037001 -0.5067722 -0.5046396 -0.4971342 -0.4840488 -0.4651391 -0.4403794 -0.4100691 -0.3745170 -0.3340263 -0.2889025 -0.2394627 -0.1860425 -0.1290042 -0.0687427 -0.0056928 0.0596659 0.1268038 0.1951375 0.2640271 0.3327742 0.4006224 0.4667586 0.5303165 0.5903822 0.6460016 0.6961909 0.7399482 0.7762683 0.8041594 0.8226620 0.8308689 0.8279477 0.8131626 0.7858986 0.7456830 0.6923495 0.6266665 0.5497726 0.4628802 0.3672497 0.2641650 0.1549106 0.0407507 -0.0770894 -0.1974398 -0.3191992 -0.4413459 -0.5629462 -0.6831597 -0.8012428 -0.9165494 -1.0285301 -1.1367292 -1.2407808 -1.3404032 -1.4353926 -1.5256164 -1.6110060 -1.6915491 -1.7672827 -1.8382853 -1.9046710 -1.9665820 -2.0241833 -2.0776572 -2.1271982
Elf2 2.326083 2.221356 2.117630 2.015036 1.913696 1.813730 1.715252 1.618375 1.523203 1.4298414 1.3383875 1.2489370 1.1615819 1.0764108 0.9935095 0.9129605 0.8348441 0.7592380 0.6862178 0.6158572 0.5482283 0.4834016 0.4214469 0.3624328 0.3064276 0.2534992 0.2037159 0.1571460 0.1138587 0.0739245 0.0374150 0.0044036 -0.0250341 -0.0508198 -0.0728726 -0.0911080 -0.1054381 -0.1157706 -0.1220126 -0.1242437 -0.1227774 -0.1179396 -0.1100531 -0.0994383 -0.0864146 -0.0713013 -0.0544182 -0.0360863 -0.0166284 0.0036301 0.0243615 0.0452352 0.0659175 0.0860718 0.1053589 0.1234369 0.1399617 0.1545876 0.1669679 0.1767554 0.1836037 0.1871678 0.1871054 0.1830782 0.1747530 0.1618032 0.1439107 0.1207672 0.0920760 0.0576171 0.0175294 -0.0279228 -0.0784690 -0.1338339 -0.1937389 -0.2579025 -0.3260423 -0.3978754 -0.4731197 -0.5514948 -0.6327228 -0.7165293 -0.8026439 -0.8908011 -0.9807412 -1.0722102 -1.1649610 -1.2587537 -1.3533557 -1.4485425 -1.5440977 -1.6398134 -1.7354902 -1.8309375 -1.9259737 -2.0204258 -2.1141298 -2.2069306 -2.2986817 -2.3892450
Ybx1 2.236275 2.142877 2.049650 1.956717 1.864203 1.772230 1.680923 1.590403 1.500793 1.4122155 1.3247930 1.2386470 1.1538992 1.0706709 0.9890833 0.9092575 0.8313140 0.7553736 0.6815566 0.6099832 0.5407735 0.4740475 0.4099249 0.3485256 0.2899692 0.2343753 0.1818634 0.1325532 0.0865642 0.0440160 0.0050284 -0.0302788 -0.0617858 -0.0893724 -0.1129183 -0.1323032 -0.1474061 -0.1581061 -0.1642863 -0.1660197 -0.1636363 -0.1574839 -0.1479101 -0.1352624 -0.1198880 -0.1021344 -0.0823490 -0.0608791 -0.0380725 -0.0142768 0.0101600 0.0348897 0.0595640 0.0838343 0.1073519 0.1297677 0.1507326 0.1698974 0.1869126 0.2014287 0.2130963 0.2215659 0.2264881 0.2275139 0.2242942 0.2164805 0.2037247 0.1856792 0.1619970 0.1323972 0.0969565 0.0558735 0.0093473 -0.0424226 -0.0992364 -0.1608941 -0.2271955 -0.2979401 -0.3729276 -0.4519574 -0.5348290 -0.6213421 -0.7112963 -0.8044913 -0.9007274 -0.9998046 -1.1015235 -1.2056850 -1.3120902 -1.4205407 -1.5308384 -1.6427858 -1.7561858 -1.8708418 -1.9865578 -2.1031382 -2.2203882 -2.3381134 -2.4561203 -2.5742157
Hmgb3 2.484765 2.361251 2.238733 2.117402 1.997446 1.879045 1.762375 1.647605 1.534899 1.4244149 1.3163042 1.2107117 1.1077761 1.0076296 0.9103980 0.8162010 0.7251522 0.6373594 0.5529251 0.4719463 0.3945154 0.3207206 0.2506463 0.1843737 0.1219813 0.0635460 0.0091434 -0.0411514 -0.0872628 -0.1291139 -0.1666258 -0.1997166 -0.2283003 -0.2522862 -0.2715777 -0.2860713 -0.2956557 -0.3002109 -0.2996120 -0.2939440 -0.2835798 -0.2689060 -0.2503046 -0.2281552 -0.2028372 -0.1747311 -0.1442210 -0.1116951 -0.0775473 -0.0421779 -0.0059941 0.0305894 0.0671503 0.1032591 0.1384791 0.1723667 0.2044727 0.2343427 0.2615183 0.2855386 0.3059414 0.3222647 0.3340489 0.3408387 0.3421850 0.3376477 0.3267982 0.3092223 0.2845236 0.2524084 0.2130510 0.1667939 0.1139934 0.0550179 -0.0097534 -0.0799318 -0.1551210 -0.2349178 -0.3189145 -0.4066995 -0.4978594 -0.5919805 -0.6886505 -0.7874598 -0.8880040 -0.9898850 -1.0927132 -1.1961091 -1.2997053 -1.4031480 -1.5060990 -1.6082367 -1.7092583 -1.8088806 -1.9068411 -2.0028991 -2.0968364 -2.1884577 -2.2775908 -2.3640864
Zfp131 2.381023 2.257747 2.135936 2.015755 1.897363 1.780910 1.666541 1.554392 1.444593 1.3372688 1.2325369 1.1305096 1.0312936 0.9349909 0.8416986 0.7515097 0.6645133 0.5807953 0.5004385 0.4235232 0.3501278 0.2803290 0.2142026 0.1518237 0.0932675 0.0386098 -0.0120729 -0.0587021 -0.1011974 -0.1394755 -0.1734496 -0.2030290 -0.2281185 -0.2486171 -0.2644182 -0.2754080 -0.2814655 -0.2824611 -0.2782613 -0.2689497 -0.2549074 -0.2365315 -0.2142156 -0.1883517 -0.1593323 -0.1275519 -0.0934087 -0.0573055 -0.0196511 0.0191392 0.0586424 0.0984279 0.1380571 0.1770833 0.2150520 0.2515014 0.2859630 0.3179627 0.3470218 0.3726583 0.3943889 0.4117307 0.4242033 0.4313311 0.4326461 0.4276907 0.4160206 0.3972079 0.3708449 0.3366326 0.2947627 0.2456019 0.1895304 0.1269387 0.0582258 -0.0162035 -0.0959406 -0.1805751 -0.2696968 -0.3628978 -0.4597739 -0.5599264 -0.6629636 -0.7685022 -0.8761686 -0.9855996 -1.0964442 -1.2083637 -1.3210327 -1.4341401 -1.5473889 -1.6604971 -1.7731979 -1.8852395 -1.9963857 -2.1064153 -2.2151224 -2.3223160 -2.4278196 -2.5314710
Myef2 2.126145 2.071784 2.017625 1.963647 1.909831 1.856161 1.802617 1.749182 1.695839 1.6425702 1.5893603 1.5361929 1.4830523 1.4299234 1.3767914 1.3236421 1.2704616 1.2172365 1.1639540 1.1106017 1.0571677 1.0036407 0.9500098 0.8962647 0.8423958 0.7883939 0.7342505 0.6799576 0.6255079 0.5708946 0.5161119 0.4611542 0.4060169 0.3506960 0.2951883 0.2394911 0.1836026 0.1275218 0.0712501 0.0148566 -0.0415012 -0.0976640 -0.1534777 -0.2087932 -0.2634668 -0.3173597 -0.3703388 -0.4222756 -0.4730470 -0.5225349 -0.5706256 -0.6172104 -0.6621844 -0.7054470 -0.7469013 -0.7864534 -0.8240124 -0.8594900 -0.8927995 -0.9238560 -0.9525751 -0.9788731 -1.0026656 -1.0238675 -1.0423920 -1.0581499 -1.0710488 -1.0809928 -1.0878809 -1.0916338 -1.0923120 -1.0900196 -1.0848544 -1.0769087 -1.0662701 -1.0530223 -1.0372452 -1.0190162 -0.9984100 -0.9754999 -0.9503578 -0.9230550 -0.8936625 -0.8622516 -0.8288945 -0.7936641 -0.7566351 -0.7178839 -0.6774894 -0.6355327 -0.5920980 -0.5472723 -0.5011462 -0.4538137 -0.4053726 -0.3559245 -0.3055749 -0.2544336 -0.2026144 -0.1502353
E2f8 2.296814 2.231562 2.167264 2.103738 2.040818 1.978347 1.916182 1.854190 1.792249 1.7302520 1.6681000 1.6057073 1.5429999 1.4799154 1.4164035 1.3524259 1.2879566 1.2229813 1.1574983 1.0915178 1.0250618 0.9581644 0.8908713 0.8232392 0.7553359 0.6872394 0.6190376 0.5508276 0.4827144 0.4148108 0.3472360 0.2801144 0.2135748 0.1477489 0.0827703 0.0187729 -0.0441104 -0.1057489 -0.1660125 -0.2246585 -0.2813301 -0.3357335 -0.3876454 -0.4369068 -0.4834158 -0.5271208 -0.5680127 -0.6061183 -0.6414937 -0.6742179 -0.7043875 -0.7321113 -0.7575064 -0.7806944 -0.8017980 -0.8209385 -0.8382334 -0.8537950 -0.8677287 -0.8801318 -0.8910927 -0.9006901 -0.9089920 -0.9160556 -0.9219258 -0.9266354 -0.9302031 -0.9326332 -0.9339134 -0.9340243 -0.9329859 -0.9308186 -0.9275244 -0.9230883 -0.9174791 -0.9106493 -0.9025359 -0.8930594 -0.8821241 -0.8696169 -0.8554068 -0.8393436 -0.8212570 -0.8009553 -0.7782238 -0.7528242 -0.7244925 -0.6929383 -0.6578434 -0.6188613 -0.5756166 -0.5277050 -0.4746940 -0.4161241 -0.3515113 -0.2803502 -0.2021191 -0.1162855 -0.0223144 0.0803225
Onecut2 1.958698 1.896456 1.835369 1.775439 1.716666 1.659051 1.602593 1.547287 1.493130 1.4401190 1.3882466 1.3375068 1.2878923 1.2393952 1.1920067 1.1457175 1.1005178 1.0563972 1.0133448 0.9713494 0.9303994 0.8904830 0.8515878 0.8137016 0.7768118 0.7409056 0.7059701 0.6719926 0.6389600 0.6068594 0.5756779 0.5454027 0.5160210 0.4875201 0.4598876 0.4331112 0.4071786 0.3820780 0.3577951 0.3342067 0.3110498 0.2880650 0.2650065 0.2416421 0.2177537 0.1931374 0.1676048 0.1409839 0.1131204 0.0838788 0.0531446 0.0208248 -0.0131497 -0.0488232 -0.0862138 -0.1253125 -0.1660822 -0.2084579 -0.2523461 -0.2976255 -0.3441482 -0.3917411 -0.4402078 -0.4893314 -0.5388777 -0.5885983 -0.6382352 -0.6875250 -0.7362031 -0.7839880 -0.8305087 -0.8754150 -0.9184222 -0.9593088 -0.9979126 -1.0341260 -1.0678912 -1.0991936 -1.1280562 -1.1545334 -1.1787051 -1.2006715 -1.2205475 -1.2384588 -1.2545374 -1.2689182 -1.2817365 -1.2931250 -1.3032126 -1.3121223 -1.3199708 -1.3268672 -1.3329130 -1.3382017 -1.3428190 -1.3468428 -1.3503435 -1.3533846 -1.3560228 -1.3583087
Gm5141 1.719215 1.685090 1.651235 1.617614 1.584193 1.550940 1.517823 1.484811 1.451877 1.4189899 1.3861248 1.3532552 1.3203565 1.2874053 1.2543791 1.2212566 1.1880179 1.1546439 1.1211169 1.0874203 1.0535387 1.0194579 0.9851650 0.9506480 0.9158966 0.8809013 0.8456541 0.8101481 0.7743778 0.7383389 0.7020284 0.6654446 0.6285869 0.5914562 0.5540545 0.5163854 0.4784533 0.4402643 0.4018256 0.3631559 0.3242872 0.2852521 0.2460829 0.2068114 0.1674689 0.1280861 0.0886932 0.0493197 0.0099946 -0.0292538 -0.0683981 -0.1074114 -0.1462676 -0.1849414 -0.2234082 -0.2616443 -0.2996269 -0.3373337 -0.3747437 -0.4118365 -0.4485925 -0.4849931 -0.5210207 -0.5566582 -0.5918898 -0.6267004 -0.6610758 -0.6950025 -0.7284683 -0.7614600 -0.7939581 -0.8259424 -0.8573947 -0.8882988 -0.9186403 -0.9484068 -0.9775877 -1.0061738 -1.0341580 -1.0615343 -1.0882983 -1.1144473 -1.1399794 -1.1648945 -1.1891932 -1.2128774 -1.2359501 -1.2584151 -1.2802771 -1.3015418 -1.3222155 -1.3423050 -1.3618181 -1.3807630 -1.3991482 -1.4169830 -1.4342769 -1.4510398 -1.4672818 -1.4830134
Zbtb40 1.878808 1.826993 1.775823 1.725297 1.675412 1.626167 1.577559 1.529585 1.482244 1.4355311 1.3894444 1.3439804 1.2991356 1.2549066 1.2112897 1.1682812 1.1258770 1.0840733 1.0428659 1.0022506 0.9622230 0.9227787 0.8839133 0.8456221 0.8079005 0.7707438 0.7341472 0.6981059 0.6626149 0.6276695 0.5932645 0.5593950 0.5260559 0.4932422 0.4609488 0.4291705 0.3979023 0.3671390 0.3368746 0.3070721 0.2776536 0.2485419 0.2196633 0.1909471 0.1623262 0.1337364 0.1051172 0.0764109 0.0475632 0.0185231 -0.0107572 -0.0403220 -0.0702123 -0.1004656 -0.1311159 -0.1621935 -0.1937250 -0.2257334 -0.2582378 -0.2912533 -0.3247913 -0.3588588 -0.3934591 -0.4285913 -0.4642503 -0.5004272 -0.5371086 -0.5742772 -0.6119119 -0.6499767 -0.6883765 -0.7270005 -0.7657431 -0.8045043 -0.8431896 -0.8817105 -0.9199843 -0.9579342 -0.9954892 -1.0325842 -1.0691598 -1.1051624 -1.1405438 -1.1752609 -1.2092762 -1.2425567 -1.2750743 -1.3068055 -1.3377308 -1.3678349 -1.3971061 -1.4255364 -1.4531210 -1.4798579 -1.5057482 -1.5307953 -1.5550051 -1.5783854 -1.6009460 -1.6226983
Wdhd1 1.937591 1.883816 1.830725 1.778310 1.726563 1.675474 1.625036 1.575241 1.526079 1.4775436 1.4296264 1.3823196 1.3356156 1.2895067 1.2439854 1.1990444 1.1546764 1.1108742 1.0676307 1.0249390 0.9827922 0.9411834 0.9001061 0.8595535 0.8195193 0.7799969 0.7409801 0.7024627 0.6644384 0.6269012 0.5898452 0.5532644 0.5171531 0.4815055 0.4463160 0.4115789 0.3772889 0.3434405 0.3100278 0.2770229 0.2443694 0.2120120 0.1798987 0.1479802 0.1162106 0.0845468 0.0529485 0.0213788 -0.0101967 -0.0418092 -0.0734870 -0.1052555 -0.1371372 -0.1691515 -0.2013149 -0.2336409 -0.2661401 -0.2988201 -0.3316853 -0.3647375 -0.3979753 -0.4313945 -0.4649879 -0.4987454 -0.5326544 -0.5666993 -0.6008620 -0.6351216 -0.6694550 -0.7038290 -0.7381691 -0.7723910 -0.8064154 -0.8401688 -0.8735828 -0.9065944 -0.9391461 -0.9711856 -1.0026659 -1.0335448 -1.0637855 -1.0933554 -1.1222271 -1.1503770 -1.1777860 -1.2044388 -1.2303240 -1.2554334 -1.2797622 -1.3033085 -1.3260734 -1.3480602 -1.3692748 -1.3897250 -1.4094206 -1.4283731 -1.4465952 -1.4641012 -1.4809064 -1.4970271
Mybl1 1.817529 1.787012 1.756658 1.726375 1.696075 1.665671 1.635081 1.604226 1.573029 1.5414185 1.5093243 1.4766814 1.4434278 1.4095057 1.3748613 1.3394449 1.3032113 1.2661199 1.2281346 1.1892244 1.1493634 1.1085308 1.0667113 1.0238953 0.9800786 0.9352631 0.8894566 0.8426727 0.7949314 0.7462586 0.6966864 0.6462529 0.5950025 0.5429852 0.4902571 0.4368797 0.3829199 0.3284500 0.2735488 0.2183782 0.1631969 0.1082511 0.0537659 -0.0000551 -0.0530290 -0.1049940 -0.1558080 -0.2053484 -0.2535109 -0.3002085 -0.3453707 -0.3889418 -0.4308799 -0.4711558 -0.5097515 -0.5466593 -0.5818802 -0.6154230 -0.6473033 -0.6775420 -0.7061649 -0.7332011 -0.7586828 -0.7826439 -0.8051198 -0.8261463 -0.8457590 -0.8639929 -0.8808818 -0.8964670 -0.9108367 -0.9240875 -0.9363072 -0.9475758 -0.9579666 -0.9675465 -0.9763770 -0.9845144 -0.9920109 -0.9989147 -1.0052704 -1.0111197 -1.0165013 -1.0214516 -1.0260047 -1.0301929 -1.0340466 -1.0375948 -1.0408652 -1.0438843 -1.0466773 -1.0492690 -1.0516828 -1.0539420 -1.0560688 -1.0580851 -1.0600122 -1.0618711 -1.0636823 -1.0654659
Tax1bp1 1.702802 1.673959 1.645138 1.616310 1.587451 1.558534 1.529534 1.500425 1.471181 1.4417780 1.4121904 1.3823934 1.3523624 1.3220731 1.2915011 1.2606224 1.2294133 1.1978501 1.1659096 1.1335686 1.1008041 1.0675937 1.0339149 0.9997456 0.9650639 0.9298484 0.8940777 0.8577309 0.8207873 0.7832267 0.7450290 0.7061746 0.6666442 0.6264189 0.5854801 0.5438097 0.5013901 0.4582038 0.4142352 0.3695140 0.3241314 0.2781816 0.2317580 0.1849529 0.1378576 0.0905623 0.0431562 -0.0042728 -0.0516380 -0.0988535 -0.1458349 -0.1924988 -0.2387630 -0.2845464 -0.3297690 -0.3743519 -0.4182173 -0.4612884 -0.5034894 -0.5447455 -0.5849825 -0.6241276 -0.6621081 -0.6988527 -0.7342902 -0.7683504 -0.8009631 -0.8320591 -0.8615690 -0.8894397 -0.9157039 -0.9404230 -0.9636571 -0.9854657 -1.0059073 -1.0250395 -1.0429194 -1.0596032 -1.0751467 -1.0896048 -1.1030321 -1.1154826 -1.1270100 -1.1376673 -1.1475075 -1.1565828 -1.1649456 -1.1726476 -1.1797404 -1.1862756 -1.1923042 -1.1978773 -1.2030459 -1.2078606 -1.2123722 -1.2166310 -1.2206877 -1.2245925 -1.2283957 -1.2321476
heatmap_matrix_q_value_0.01 <- left_join(select(transcription_factors_table_q_value_0.01, gene, pval, qval, num_cells_expressed), heatmap_matrix_q_value_0.01)
write.table(heatmap_matrix_q_value_0.01, file = file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22-significant_transcription_factors_diff_test_analysis_qval_0.01_heatmap_matrix.txt"), sep="\t", quote=FALSE, row.names=FALSE)
2.2.2.1.4 Ordered pseudotime heatmap (Sam’s function)
ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_0.01,], show_rownames=FALSE, return_matrix = FALSE)

ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_0.01,], show_rownames=FALSE, return_matrix = FALSE)

ordered_matrix <- ordered_pseudotime_heatmap(monocle[significant_transcription_factors_q_value_0.01,], show_rownames=TRUE, return_matrix = TRUE)

ordered_matrix <- as.data.frame(ordered_matrix) %>% rownames_to_column("gene")
ordered_matrix <- left_join(select(transcription_factors_table_q_value_0.01, gene, pval, qval, num_cells_expressed), ordered_matrix)
write.table(ordered_matrix, file = file.path(tables_directory, "3_forebrain_oligodendrocytes_joint_forebrain_differential_gene_test_analysis_qval_0.01_sam_ordered_heatmap_matrix.txt"), sep="\t", quote=FALSE, row.names=FALSE)
2.2.2.1.5 Plotting of transcription factors differentially expressed in pseudotime
2.2.2.1.5.1 Top 10 differentially expressed genes (q value < 5*10^-5)
transcription_factors_table_q_value_5_10_minus_5_ordered_qval <- arrange(transcription_factors_table_q_value_5_10_minus_5, qval)
marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[1]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[2]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[3]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[4]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[5]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[6]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[7]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[8]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[9]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

marker <- transcription_factors_table_q_value_5_10_minus_5_ordered_qval$gene[10]
p1 <- plot_cell_trajectory(monocle, markers=marker)
p2 <- plot_cell_trajectory(monocle, use_color_gradient = TRUE, markers=marker)
show(p1+p2)

2.3 Selected genes

# Genes of interest.
genes_of_interest <- c("Pdgfra", "Top2a", "Cspg4", "Fyn", "Mbp", "Mol")

# Remove genes of interest not present in Seurat dataset
genes_not_present <- genes_of_interest[!genes_of_interest %in% rownames(seurat@data)]
genes_of_interest <- genes_of_interest[!genes_of_interest %in% genes_not_present]
if(length(genes_not_present != 0)) {
  print(paste0("The following genes were not present in the Seurat object", genes_not_present))
}
## [1] "The following genes were not present in the Seurat objectMol"
diff_test_res <- differentialGeneTest(monocle[genes_of_interest],
      fullModelFormulaStr = "~sm.ns(Pseudotime)")
sig_gene_names <- row.names(subset(diff_test_res, qval < 0.1))
plot_pseudotime_heatmap(monocle[genes_of_interest,],
      num_clusters = 1,
      cores = 1,
      show_rownames = T)

2.3.1 Genes in pseudotime, single branch (Selected genes)

p <- plot_genes_in_pseudotime(monocle[genes_of_interest,], color_by="cluster") + scale_color_manual(values=colours)
p <- p %>% remove_geom("point")
p <- p %>% remove_geom("Line")
p <- p %>% + geom_line(aes(x = Pseudotime, y = expectation), size=1)
show(p)

2.3.2 Genes in pseudotime with branches (Selected genes)

p <- plot_genes_branched_pseudotime(monocle[genes_of_interest,], color_by="cluster") + scale_color_manual(values=colours)
show(p)

p <- p %>% remove_geom("point")
show(p)

3 Seurat tSNE plots

p <- cytokit::tsne(seurat, label=FALSE)
show(p)

p <- tsne_plot_clusters_highlighted(seurat, selected_clusters, legend=TRUE)
show(p)

p <- p + theme(legend.position = "none")
show(p)

p <- tsne_plot_clusters_highlighted_with_pseudotime(seurat, monocle, selected_clusters, legend=TRUE)
show(p)

p <- p + theme(legend.position = "none")
show(p)

4 Save monocle object to directory, and write pseudotime of cells to table.

save(monocle, file=file.path(monocle_objects_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22.Rda"))
cells_pseudotime <- pData(monocle) %>% select(cell, Pseudotime) %>% rename(pseudotime=Pseudotime)
write.table(cells_pseudotime, file.path(tables_directory, "3-forebrain_oligodendrocytes_joint_cortex_clusters_14_22_cell_pseudotime.txt"), sep="\t", quote=FALSE, row.names=FALSE)

5 Session info

sessionInfo()
## R version 3.5.0 (2018-04-23)
## Platform: x86_64-redhat-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
## 
## Matrix products: default
## BLAS/LAPACK: /var/chroots/hydraex-centos-7/usr/lib64/R/lib/libRblas.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
##  [1] splines   stats4    parallel  stats     graphics  grDevices utils    
##  [8] datasets  methods   base     
## 
## other attached packages:
##  [1] viridis_0.5.1       viridisLite_0.3.0   forcats_0.4.0      
##  [4] stringr_1.4.0       dplyr_0.8.0.1       purrr_0.3.0        
##  [7] tidyr_0.8.2         tibble_2.0.1        tidyverse_1.2.1    
## [10] Seurat_2.3.4        cowplot_0.9.4       R.utils_2.8.0      
## [13] R.oo_1.22.0         R.methodsS3_1.7.1   readr_1.3.1        
## [16] readxl_1.3.0        patchwork_0.0.1     monocle_2.10.1     
## [19] DDRTree_0.1.5       irlba_2.3.3         VGAM_1.1-1         
## [22] Biobase_2.42.0      BiocGenerics_0.28.0 Matrix_1.2-15      
## [25] kableExtra_1.0.1    ggedit_0.3.0        ggplot2_3.1.0      
## [28] cytokit_0.6.0       pheatmap_1.0.12     colorRamps_2.3     
## 
## loaded via a namespace (and not attached):
##   [1] snow_0.4-3           backports_1.1.3      Hmisc_4.2-0         
##   [4] plyr_1.8.4           igraph_1.2.4         lazyeval_0.2.2      
##   [7] densityClust_0.3     fastICA_1.2-1        digest_0.6.18       
##  [10] foreach_1.4.4        htmltools_0.3.6      lars_1.2            
##  [13] gdata_2.18.0         magrittr_1.5         checkmate_1.9.1     
##  [16] cluster_2.0.7-1      mixtools_1.1.0       ROCR_1.0-7          
##  [19] limma_3.38.3         modelr_0.1.3         matrixStats_0.54.0  
##  [22] docopt_0.6.1         colorspace_1.4-0     ggrepel_0.8.0       
##  [25] rvest_0.3.2          haven_2.0.0          xfun_0.4            
##  [28] sparsesvd_0.1-4      crayon_1.3.4         jsonlite_1.6        
##  [31] survival_2.43-3      zoo_1.8-4            iterators_1.0.10    
##  [34] ape_5.2              glue_1.3.0           gtable_0.2.0        
##  [37] webshot_0.5.1        kernlab_0.9-27       prabclus_2.2-7      
##  [40] DEoptimR_1.0-8       scales_1.0.0         mvtnorm_1.0-8       
##  [43] bibtex_0.4.2         miniUI_0.1.1.1       Rcpp_1.0.0          
##  [46] metap_1.1            dtw_1.20-1           xtable_1.8-3        
##  [49] htmlTable_1.13.1     reticulate_1.11.1    foreign_0.8-71      
##  [52] bit_1.1-14           proxy_0.4-22         mclust_5.4.2        
##  [55] SDMTools_1.1-221     Formula_1.2-3        tsne_0.1-3          
##  [58] htmlwidgets_1.3      httr_1.4.0           FNN_1.1.3           
##  [61] gplots_3.0.1.1       RColorBrewer_1.1-2   shinyAce_0.3.3      
##  [64] fpc_2.1-11.1         acepack_1.4.1        modeltools_0.2-22   
##  [67] ica_1.0-2            pkgconfig_2.0.2      flexmix_2.3-14      
##  [70] nnet_7.3-12          labeling_0.3         tidyselect_0.2.5    
##  [73] rlang_0.3.1          reshape2_1.4.3       later_0.8.0         
##  [76] cellranger_1.1.0     munsell_0.5.0        tools_3.5.0         
##  [79] cli_1.0.1            generics_0.0.2       broom_0.5.1         
##  [82] ggridges_0.5.1       evaluate_0.13        shinyBS_0.61        
##  [85] yaml_2.2.0           npsurv_0.4-0         knitr_1.21          
##  [88] bit64_0.9-7          fitdistrplus_1.0-14  robustbase_0.93-3   
##  [91] caTools_1.17.1.1     randomForest_4.6-14  RANN_2.6.1          
##  [94] pbapply_1.4-0        nlme_3.1-137         mime_0.6            
##  [97] slam_0.1-44          xml2_1.2.0           hdf5r_1.0.0         
## [100] compiler_3.5.0       rstudioapi_0.9.0     png_0.1-7           
## [103] lsei_1.2-0           stringi_1.3.1        highr_0.7           
## [106] lattice_0.20-35      trimcluster_0.1-2.1  HSMMSingleCell_1.2.0
## [109] pillar_1.3.1         combinat_0.0-8       Rdpack_0.10-1       
## [112] lmtest_0.9-36        data.table_1.12.0    bitops_1.0-6        
## [115] gbRd_0.4-11          httpuv_1.5.1         R6_2.4.0            
## [118] latticeExtra_0.6-28  promises_1.0.1       KernSmooth_2.23-15  
## [121] gridExtra_2.3        codetools_0.2-15     MASS_7.3-51.1       
## [124] gtools_3.8.1         assertthat_0.2.0     withr_2.1.2         
## [127] qlcMatrix_0.9.7      diptest_0.75-7       doSNOW_1.0.16       
## [130] hms_0.4.2            grid_3.5.0           rpart_4.1-13        
## [133] class_7.3-14         rmarkdown_1.11       segmented_0.5-3.0   
## [136] Rtsne_0.15           lubridate_1.7.4      shiny_1.2.0         
## [139] base64enc_0.1-3